package com.peanut.sql.lineage.postgresql;

import java.util.List;
import java.util.Objects;

/****
 author:yifan
 date:2016
 description:
 **/
public class Database extends Vertex {
    private String connectionId;
    private String databaseName;
    private List<Schema> schemas;

    public Database(String connectionId, String databaseName, List<Schema> schemas) {
        this.connectionId = connectionId;
        this.databaseName = databaseName;
        this.schemas = schemas;
    }

    public Database() {
    }

    public String getConnectionId() {
        return connectionId;
    }

    public void setConnectionId(String connectionId) {
        this.connectionId = connectionId;
    }

    public String getDatabaseName() {
        return databaseName;
    }

    public void setDatabaseName(String databaseName) {
        this.databaseName = databaseName;
    }

    public List<Schema> getSchemas() {
        return schemas;
    }

    public void setSchemas(List<Schema> schemas) {
        this.schemas = schemas;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Database database = (Database) o;
        return Objects.equals(connectionId, database.connectionId) &&
                Objects.equals(databaseName, database.databaseName) &&
                Objects.equals(schemas, database.schemas);
    }

    @Override
    public int hashCode() {
        return Objects.hash(connectionId, databaseName, schemas);
    }

    @Override
    public String toString() {
        return databaseName + "." + schemas;
    }
}
